#ifndef __JUNIX_H
#define __JUNIX_H

#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <ctime>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <tr1/unordered_map>
#include <tr1/unordered_set>
#include <ext/hash_map>
#include <ext/hash_set>
#include <memory>
#include <set>
#include <iterator>
#include <functional>
#include <boost/bind.hpp>
#include <boost/timer.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/shared_array.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/scoped_array.hpp>
#include <boost/foreach.hpp>
#include <boost/mem_fn.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/any.hpp>
#include <boost/format.hpp>
#include <boost/signal.hpp>
#include <boost/array.hpp>

#include <unistd.h>
#include <fcntl.h>
#include <errno.h>

class jtime{
	public:
		jtime():ticks_(0),start_(0),end_(0) {  }
		~jtime(){ }

		void begin() { this->start(); }

		void start() {
			start_ = clock();
			end_ = start_;
		}

		void end() {
			end_ = clock();
			ticks_ += end_-start_;
			start_ = end_;
		}

		void reset() {
			start_ = 0;
			end_ = 0;
			ticks_= 0;
		}

		void restart() {
			start_ = clock();
			end_ = start_;
			ticks_= 0;
		}

		clock_t get() {
			return ticks_;
		}

		void print(std::ostream& os = std::cout) {
			os<<"Ticks:"<<ticks_<<std::endl;
			os<<"Seconds:"
				<<static_cast<double>(ticks_)/CLOCKS_PER_SEC
				<<std::endl;
		}

	private:
		clock_t ticks_;
		clock_t start_;
		clock_t end_;
};

#endif
